<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
Class Master_user extends CI_Controller {	
    function __construct(){  
        parent::__construct();  
		$this->load->model('mod_master_user');
		$this->load->library('datatables');
    }
	public function index(){
	    if ($this->session->userdata('type') == 'admin') {
			$data['hasil'] = $this->mod_master_user->getall();
			$datum['content'] = $this->load->view('master_user/view',$data,true);
			$this->load->view('main',$datum);
        } else if ($this->session->userdata('type') == 'user'){
            $a= $this->load->model('m_absensi');
            $aa["content"] = $this->load->view('absensi/form',$a,true);
            $this->load->view("absensi/mainUser",$aa);
        }
	}
    
    public function json_tampil()
	{
		$this->load->model('mod_master_user');
		$data = $this->mod_master_user->getdata_json();
        
        $this->load->library('Datatables');
	
		$this->datatables->select('ID_USER,NAMA,TANGGAL_LAHIR,TEMPAT_LAHIR,ROLE')
             ->from('master_user');
          
            
             echo $this->datatables->generate();
	}

	public function tambah_data(){
 
		if($this->input->post('nama')){
			$this->mod_master_user->tambah();
			redirect('master_user');
		}else{
		$this->load->view('master_user/add'); 
		}
	}

	public function update_data($id_user){
		if($this->input->post('submit')){
			$this->mod_master_user->update($id_user);
			redirect('master_user/index');
		}
		$data['hasil']=$this->mod_master_user->getById($id_user);
		$this->load->view('master_user/edit',$data);
	}

	public function delete_data($id_user){
		$this->mod_master_user->delete($id_user);
		redirect('master_user');
	}

	public function error() 
    { 
        $this->output->set_status_header('404'); 
        $data['content'] = '404';  
        $this->load->view('master_user/404',$data); 
    }

    public function print_report()
    {
    	$this->load->view('master_user/print');
    }

    public function jam_masuk()
    {
    	$this->load->view('master_user/jam_masuk');
    }
    
   	public function getid($id_user){
	$data['hasil']=$this->mod_master_user->getById($id_user);
    $this->load->view('barcode_view',$data);
    
	}
    
   
}